package com.tencent.trtc.apiexample;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import static com.tencent.trtc.apiexample.LoginActivity.PATH;

public class RegisterActivity extends AppCompatActivity {
    private EditText mRegister_UserName;
    private EditText mRegister_UserPwd;
    private EditText mRegister_UserTel;
    private EditText mRegister_UserEmail;
    private Button mRegister_Confirm;

    private String username = "";
    private String password = "";
    private String telphone = "";
    private String email = "";
    private String info = "";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        mRegister_UserName=findViewById(R.id.Register_UserName);
        mRegister_UserPwd=findViewById(R.id.Register_UserPwd);
        mRegister_UserTel=findViewById(R.id.Register_UserTel);
        mRegister_UserEmail=findViewById(R.id.Register_UserEmail);
        mRegister_Confirm=findViewById(R.id.Register_Confirm);


        mRegister_Confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                username = mRegister_UserName.getText().toString();
                password = mRegister_UserPwd.getText().toString();
                telphone = mRegister_UserTel.getText().toString();
                email = mRegister_UserEmail.getText().toString();
                new Thread(new MyThread()).start();

            }
        });
    }
    class MyThread implements Runnable {

        @Override
        public void run() {
            String path = PATH + "/reg?username=" + username + "&password=" + password + "&telephone=" + telphone + "&email=" +email;
            info = WebServiceGet.executeHttpGet(path);
            Intent intent = new Intent(RegisterActivity.this,LoginActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);;
            intent.putExtra("reginfo",info);
            startActivity(intent);
        }
    }
}